home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Fades ƒ / Split scroll U-D fade.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-11  |  3.6 KB  |  123 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Split scroll U-D fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define CorrectTime 4
  32. #define theWindowWidth (boundsRect.right-boundsRect.left)
  33. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  34.  
  35. pascal short SplitScrollUDFade(Rect boundsRect, Pattern *thePattern);
  36.  
  37. /* Draw a line from the topleft to the bottomright of the screen and split the
  38.    screen into two regions.  The top region scrolls down and the bottom region
  39.    scrolls up. */
  40.    
  41. pascal short SplitScrollUDFade(Rect boundsRect, Pattern *thePattern)
  42. {
  43.     int            x;
  44.     Rect        topdest, bottomdest;
  45.     Rect        topscrollsource, topscrolldest, bottomscrollsource, bottomscrolldest;
  46.     RgnHandle    toprgn,bottomrgn;
  47.     RgnHandle    temprgn, temp2rgn;
  48.     RgnHandle    topsectrgn, bottomsectrgn;
  49.     int            BoxSize;
  50.     GrafPtr        destGrafPtr;
  51.     
  52.     GetPort(&destGrafPtr);
  53.     
  54.     temprgn=NewRgn();
  55.     temp2rgn=NewRgn();
  56.     topsectrgn=NewRgn();
  57.     bottomsectrgn=NewRgn();
  58.     
  59.     BoxSize=theWindowHeight/25;
  60.     toprgn=NewRgn();
  61.     SetEmptyRgn(toprgn);
  62.     MoveTo(0,0);
  63.     OpenRgn();
  64.         Line(theWindowWidth,0);
  65.         Line(0,theWindowHeight);
  66.         LineTo(0,0);
  67.     CloseRgn(toprgn);
  68.     OffsetRgn(toprgn, boundsRect.left, boundsRect.top);
  69.     
  70.     bottomrgn=NewRgn();
  71.     SetEmptyRgn(bottomrgn);
  72.     MoveTo(0,0);
  73.     OpenRgn();
  74.         Line(0,theWindowHeight);
  75.         Line(theWindowWidth,0);
  76.         LineTo(0,0);
  77.     CloseRgn(bottomrgn);
  78.     OffsetRgn(bottomrgn, boundsRect.left, boundsRect.top);
  79.     
  80.     topscrollsource=boundsRect;
  81.     topscrollsource.bottom-=BoxSize;
  82.     topscrolldest = topscrollsource;
  83.     OffsetRect(&topscrolldest, 0, BoxSize);
  84.     topdest = boundsRect;
  85.     topdest.bottom=topdest.top+BoxSize;
  86.     
  87.     bottomscrollsource=boundsRect;
  88.     bottomscrollsource.top+=BoxSize;
  89.     bottomscrolldest=bottomscrollsource;
  90.     OffsetRect(&bottomscrolldest, 0, -BoxSize);
  91.     bottomdest=boundsRect;
  92.     bottomdest.top=bottomdest.bottom-BoxSize;
  93.     
  94.     SetRectRgn(temprgn, topdest.left, topdest.top, topdest.right, topdest.bottom);
  95.     SectRgn(toprgn, temprgn, topsectrgn);
  96.     
  97.     SetRectRgn(temp2rgn, bottomdest.left, bottomdest.top, bottomdest.right, bottomdest.bottom);
  98.     SectRgn(bottomrgn, temp2rgn, bottomsectrgn);
  99.     
  100.     for(x = theWindowHeight; x >= 0; x -= BoxSize)
  101.     {
  102.         StartTiming();
  103.         CopyBits(&(destGrafPtr->portBits), &(destGrafPtr->portBits),
  104.                 &topscrollsource, &topscrolldest, 0, toprgn);        
  105.         CopyBits(&(destGrafPtr->portBits), &(destGrafPtr->portBits),
  106.                 &bottomscrollsource, &bottomscrolldest, 0, bottomrgn);
  107.         
  108.         FillRgn(bottomsectrgn, *thePattern);
  109.         FillRgn(topsectrgn, *thePattern);
  110.         
  111.         TimeCorrection(CorrectTime);
  112.     }
  113.     
  114.     DisposeRgn(toprgn);
  115.     DisposeRgn(bottomrgn);
  116.     DisposeRgn(temprgn);
  117.     DisposeRgn(temp2rgn);
  118.     DisposeRgn(topsectrgn);
  119.     DisposeRgn(bottomsectrgn);
  120.     
  121.     return 0;
  122. }
  123.